﻿<UserControl x:Class="Peter.Sdw.View.TermView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:logic="clr-namespace:Peter.Sdw.Logic"
             xmlns:icons="clr-namespace:Peter.Common.Icons;assembly=Peter.Common"
             xmlns:view="clr-namespace:Peter.Sdw.View"
             mc:Ignorable="d"
             d:DesignHeight="300"
             d:DesignWidth="300" 
             d:DataContext="{d:DesignInstance logic:TermModel}">
   <Grid>
      <Grid.RowDefinitions>
         <RowDefinition Height="Auto" />
         <RowDefinition Height="Auto" />
         <RowDefinition Height="*" />
      </Grid.RowDefinitions>
      <TextBlock Grid.Row="0"
                 Text="Term Name"/>
      <TextBox Grid.Row="1"
               Text="{Binding Path=Term.Name}" />
      
      <GroupBox Grid.Row="2">
         <GroupBox.Header>
            <StackPanel Orientation="Horizontal"
                        Margin="0,5">
               <TextBlock Text="Term Items"
                          VerticalAlignment="Center" />
               <Button Margin="5,0"
                       ToolTip="Add a new version for this book"
                       Command="{Binding Path=AddItemCommand}">
                  <icons:IconDisplay Icon="PlusSign"
                                     IconSize="Small"
                                     Margin="5,0" />
               </Button>
            </StackPanel>
         </GroupBox.Header>
         <Grid>
            <TabControl ItemsSource="{Binding Path=Items}"
                        SelectedValue="{Binding Path=SelectedItem}">
               <TabControl.ItemTemplate>
                  <DataTemplate>
                     <TextBlock Text="{Binding Path=Item.Source}" />
                  </DataTemplate>
               </TabControl.ItemTemplate>
               <TabControl.ContentTemplate>
                  <DataTemplate DataType="{x:Type logic:TermItemModel}">
                     <view:TermItemView />
                  </DataTemplate>
               </TabControl.ContentTemplate>
            </TabControl>

            <Border Grid.Row="0"
                    Height="75"
                    Width="150"
                    CornerRadius="5"
                    Background="SteelBlue"
                    Visibility="{Binding Path=IsLoading, Converter={StaticResource _BoolToVisi}}">
               <TextBlock Text="Loading..."
                          FontSize="16"
                          Foreground="White"
                          FontStyle="Italic"
                          HorizontalAlignment="Center"
                          VerticalAlignment="Center" />
            </Border>
         </Grid>
      </GroupBox>
   </Grid>
</UserControl>
